home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / ncurses-5.3 / ncurses / base / lib_box.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-27  |  4.7 KB  |  127 lines

  1. /****************************************************************************
  2.  * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
  3.  *                                                                          *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a  *
  5.  * copy of this software and associated documentation files (the            *
  6.  * "Software"), to deal in the Software without restriction, including      *
  7.  * without limitation the rights to use, copy, modify, merge, publish,      *
  8.  * distribute, distribute with modifications, sublicense, and/or sell       *
  9.  * copies of the Software, and to permit persons to whom the Software is    *
  10.  * furnished to do so, subject to the following conditions:                 *
  11.  *                                                                          *
  12.  * The above copyright notice and this permission notice shall be included  *
  13.  * in all copies or substantial portions of the Software.                   *
  14.  *                                                                          *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
  16.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
  17.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
  18.  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
  19.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
  20.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
  21.  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
  22.  *                                                                          *
  23.  * Except as contained in this notice, the name(s) of the above copyright   *
  24.  * holders shall not be used in advertising or otherwise to promote the     *
  25.  * sale, use or other dealings in this Software without prior written       *
  26.  * authorization.                                                           *
  27.  ****************************************************************************/
  28.  
  29. /****************************************************************************
  30.  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  31.  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  32.  ****************************************************************************/
  33.  
  34. /*
  35. **    lib_box.c
  36. **
  37. **    The routine wborder().
  38. **
  39. */
  40.  
  41. #include <curses.priv.h>
  42.  
  43. MODULE_ID("$Id: lib_box.c,v 1.21 2002/09/15 01:04:27 tom Exp $")
  44.  
  45. #if USE_WIDEC_SUPPORT
  46. static inline chtype
  47. _my_render(WINDOW *win, chtype ch)
  48. {
  49.     NCURSES_CH_T wch;
  50.     SetChar2(wch, ch);
  51.     wch = _nc_render(win, wch);
  52.     return CharOf(wch) | AttrOf(wch);
  53. }
  54. #define RENDER_WITH_DEFAULT(ch,def) w ## ch = _my_render(win, (ch == 0) ? def : ch)
  55. #else
  56. #define RENDER_WITH_DEFAULT(ch,def) w ## ch = _nc_render(win, (ch == 0) ? def : ch)
  57. #endif
  58.  
  59. NCURSES_EXPORT(int)
  60. wborder(WINDOW *win,
  61.     chtype ls, chtype rs,
  62.     chtype ts, chtype bs,
  63.     chtype tl, chtype tr,
  64.     chtype bl, chtype br)
  65. {
  66.     NCURSES_SIZE_T i;
  67.     NCURSES_SIZE_T endx, endy;
  68.     chtype wls, wrs, wts, wbs, wtl, wtr, wbl, wbr;
  69.  
  70.     T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
  71.        win,
  72.        _tracechtype2(1, ls),
  73.        _tracechtype2(2, rs),
  74.        _tracechtype2(3, ts),
  75.        _tracechtype2(4, bs),
  76.        _tracechtype2(5, tl),
  77.        _tracechtype2(6, tr),
  78.        _tracechtype2(7, bl),
  79.        _tracechtype2(8, br)));
  80.  
  81.     if (!win)
  82.     returnCode(ERR);
  83.  
  84.     RENDER_WITH_DEFAULT(ls, ACS_VLINE);
  85.     RENDER_WITH_DEFAULT(rs, ACS_VLINE);
  86.     RENDER_WITH_DEFAULT(ts, ACS_HLINE);
  87.     RENDER_WITH_DEFAULT(bs, ACS_HLINE);
  88.     RENDER_WITH_DEFAULT(tl, ACS_ULCORNER);
  89.     RENDER_WITH_DEFAULT(tr, ACS_URCORNER);
  90.     RENDER_WITH_DEFAULT(bl, ACS_LLCORNER);
  91.     RENDER_WITH_DEFAULT(br, ACS_LRCORNER);
  92.  
  93.     T(("using %s, %s, %s, %s, %s, %s, %s, %s",
  94.        _tracechtype2(1, wls),
  95.        _tracechtype2(2, wrs),
  96.        _tracechtype2(3, wts),
  97.        _tracechtype2(4, wbs),
  98.        _tracechtype2(5, wtl),
  99.        _tracechtype2(6, wtr),
  100.        _tracechtype2(7, wbl),
  101.        _tracechtype2(8, wbr)));
  102.  
  103.     endx = win->_maxx;
  104.     endy = win->_maxy;
  105.  
  106.     for (i = 0; i <= endx; i++) {
  107.     SetChar2(win->_line[0].text[i], wts);
  108.     SetChar2(win->_line[endy].text[i], wbs);
  109.     }
  110.     win->_line[endy].firstchar = win->_line[0].firstchar = 0;
  111.     win->_line[endy].lastchar = win->_line[0].lastchar = endx;
  112.  
  113.     for (i = 0; i <= endy; i++) {
  114.     SetChar2(win->_line[i].text[0], wls);
  115.     SetChar2(win->_line[i].text[endx], wrs);
  116.     win->_line[i].firstchar = 0;
  117.     win->_line[i].lastchar = endx;
  118.     }
  119.     SetChar2(win->_line[0].text[0], wtl);
  120.     SetChar2(win->_line[0].text[endx], wtr);
  121.     SetChar2(win->_line[endy].text[0], wbl);
  122.     SetChar2(win->_line[endy].text[endx], wbr);
  123.  
  124.     _nc_synchook(win);
  125.     returnCode(OK);
  126. }
  127.